Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stdlib: Accept keyword arguments in Net::HTTP.start #2225

Merged
merged 2 commits into from
Jan 24, 2025

Conversation

euglena1215
Copy link
Contributor

In the original definition, keyword arguments could not be specified without specifying all positional arguments.

Specifically, the following call results in an error with Ruby::ArgumentTypeMismatch.

Net::HTTP.start('www.ruby-lang.org', 443, use_ssl: true)

This is because opt is treated as a hash positional argument.
This problem is solved by treating opt as a variable-length keyword argument.

ref. https://docs.ruby-lang.org/ja/latest/method/Net=3a=3aHTTP/s/start.html

euglena1215 and others added 2 commits January 24, 2025 11:29
In the original definition, keyword arguments could not be specified
without specifying all positional arguments.

Specifically, the following call results in an error with
`Ruby::ArgumentTypeMismatch`.

```rb
Net::HTTP.start('www.ruby-lang.org', 443, use_ssl: true)
```

This is because opt is treated as a hash positional argument.
This problem is solved by treating opt as a variable-length keyword argument.

ref. https://docs.ruby-lang.org/ja/latest/method/Net=3a=3aHTTP/s/start.html
@soutaro
Copy link
Member

soutaro commented Jan 24, 2025

My commit adds Hash positional parameter to keep the updated signature compatible with existing ones, while I don't think we frequently use the hash version...

@soutaro soutaro enabled auto-merge January 24, 2025 03:19
@soutaro soutaro added this to the RBS 3.9 milestone Jan 24, 2025
@soutaro soutaro added this pull request to the merge queue Jan 24, 2025
Merged via the queue into ruby:master with commit 70e340d Jan 24, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants